package com.example.demo;

import com.example.demo.data.Goods;


import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.example.demo.data.Details;
import com.example.demo.data.Orders;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;


@Controller
public class myController {


    @RequestMapping(value="/getDetails.do")
    @ResponseBody
    public Details getDetails(@RequestBody Details details){

        executeSql es = new executeSql();
        details = es.selectDetail(details.getUserId());

        return details;
    }


    @RequestMapping(value="/getGoods.do")
    @ResponseBody
    public Goods getGoods(@RequestBody Goods goods, HttpServletRequest request){
        System.out.println("getGoods():"+request.getRemoteAddr());
        executeSql es = new executeSql();
        goods = es.selectGoods();

        return goods;
    }








    @RequestMapping(value="/getOrders.do")
    @ResponseBody
    public Orders getOrders(@RequestBody Orders orders){

        executeSql es = new executeSql();
        orders = es.selectOrders();

        return orders;
    }


    @RequestMapping(value="/updateDetails.do")
    @ResponseBody
    public Details updateDetails(@RequestBody Details details){


        executeSql es = new executeSql();
        es.updateDetail(details);


        return details;
    }

    @RequestMapping(value="/insertOrder.do")
    @ResponseBody
    public Orders insertOrder(@RequestBody Orders order){
        executeSql es = new executeSql();
        es.insertOrder(order);


        return order;
    }
}
